/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.sadhar.sipp.perekamankomponenanggaranbiayagaji;

import org.sadhar.sia.framework.ClassApplicationModule;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Window;

/**
 *
 * @author hendro
 */
public class SimbolOperasiPopupWnd extends ClassApplicationModule{
    private Listbox lstboxSimbolOperasi;
    private PerekamanKomponenAnggaranBiayaGajiDAO dao;
    public SimbolOperasiPopupWnd(){
        dao = new PerekamanKomponenAnggaranBiayaGajiDAOImpl();
    }
    public void onCreate()throws Exception{
        lstboxSimbolOperasi = (Listbox)getFellow("lstboxSimbolOperasi");
        loadSimbolOperasi();
    }
    private void loadSimbolOperasi()throws Exception{
        lstboxSimbolOperasi.getItems().clear();
        for(SimbolOperasi so : dao.loadSimbolOperasi()){
            Listitem item = new Listitem();
            item.setValue(so);
            item.appendChild(new Listcell(so.getOperasi()));
            item.appendChild(new Listcell(so.getSimbol()));
            lstboxSimbolOperasi.appendChild(item);
        }
    }

    public void lstboxSimbolOperasiOnSelect()throws Exception{
        SimbolOperasi so = (SimbolOperasi)lstboxSimbolOperasi.getSelectedItem().getValue();
        Window window = (Window) this.getRoot().getFellow("contentDiv").getFirstChild();
        Textbox txtboxRumus = (Textbox) window.getFellow("txtboxRumus");
        txtboxRumus.setValue(txtboxRumus.getValue()+so.getSimbol());
        this.detach();
    }
}
